﻿@using Zocono.WCS.Admin.Models.Equipment
@{
    ViewData["Title"] = "添加调度设备";
    Layout = "_Edit";
}
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-add">
        <input type="hidden" class="input-text" value="@Model.ID" id="id" name="id">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设备名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.EquipmentName" placeholder="" id="name" name="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>区域号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.AreaCode" placeholder="" id="area" name="area">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设备代码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.EquipmentCode" placeholder="" id="code" name="code">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>工位数：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.StationCount" placeholder="" id="station" name="station">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设备类型：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <span class="select-box">
                    <select class="select" size="1" name="eqTypeId" id="eqTypeId">
                        <option value="0">--请选择--</option>
                        @foreach (var item in Model.EquipmentTypes)
                        {
                            if (Model.EquipmentTypeID + "" == item.ID)
                            {
                                <option value="@item.ID" selected>@item.TypeName</option>
                            }
                            else
                            {
                                <option value="@item.ID">@item.TypeName</option>
                            }
                        }
                    </select>
                </span>
                @*@Html.DropDownList("eqList", ViewData["eqList"] as SelectList, "请选择", new {  @class = "form-control  input-mid" })*@
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="button" onclick="operate()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

@section javascript{

<script>
    $('.skin-minimal input').iCheck({
         checkboxClass: 'icheckbox-blue',
         radioClass: 'iradio-blue',
         increaseArea: '20%'
     });
     function operate(){
         var code=$("#code").val();
         if(code==null||code=="")
         {
            popupAlert('设备代码不能为空',2,function(data){layer.close(data);});
           return;
         }
         var name=$("#name").val();
         if(name==null||name=="")
         {
            popupAlert('设备名称不能为空',2,function(data){layer.close(data);});
           return;
         }
         var area=$("#area").val();
         if(area==null||area=="")
         {
            popupAlert('设备区域号不能为空',2,function(data){layer.close(data);});
           return;
         }
         var station=$("#station").val();
         if(station==null||station=="")
         {
            popupAlert('工位数不能为空',2,function(data){layer.close(data);});
           return;
         }
         var eqList=$("#eqTypeId").val();
         if(eqList==null||eqList==""||eqList==0)
         {
            popupAlert('请选择设备类型',2,function(data){layer.close(data);});
           return;
         }
        SubmitFormForAjax("/equipment/operatedispatchequipment", $("#form-add").serialize(), function (data) {
            if (data.result) {
                    popupAlert('提交成功',1,function(){closePageLayer(true);});
            }else{
                popupAlert(data.message,2,function(data){layer.close(data);});
            }
        },true);
     }
</script>
}